﻿/*
   Author: Tomer Paz
   games.com
   2009
*/

/* Bottom Panel container (Viewer) */

package monopoly.views {
	import flash.display.Sprite;
	import flash.display.DisplayObjectContainer;
	import flash.display.DisplayObject;
	import fl.containers.ScrollPane;
	import flash.display.Stage;
	import monopoly.IFS.GLOBALS;

	public class BottomPanel extends ScrollPane
		{
		public static const BPANEL_LEFT:String		= "BPanelLeftObject";
		public static const BPANEL_CENTER:String	= "BPanelCenterObject";
		public static const BPANEL_RIGHT:String		= "BPanelRightObject";
		public static const BPANEL_RCORNER:String	= "BPanelRCornerObject";

		protected var _rootSprite:Sprite;
		
		public function BottomPanel(rootSprite:Sprite)
			{
			_rootSprite = rootSprite;
			
			with (this)
				{
				width	= GLOBALS.HPANEL_WIDTH; //_rootSprite.width  * 1;
				height  = GLOBALS.HPANEL_HEIGHT; //_rootSprite.height * 0.30;
				x		= _rootSprite.x;
				y		= _rootSprite.y + _rootSprite.height;
				alpha	= 0.9;
				setSize(width, height);
				opaqueBackground = GLOBALS.DEFAULT_BG_COLOR;
				}
			_rootSprite.addChild(this);
			}
		public override function addChild(object:DisplayObject):DisplayObject
			{
			if (BPANEL_LEFT == object.name)
				{
				object.x		= 5;
				object.y		= 1;
				object.height	= this.height * 0.92;
				object.width	= this.width * 0.25;
				}
			else if (BPANEL_CENTER == object.name)
				{
				object.x	 = 1 + this.width * 0.3;
				object.y	 = 1;
				if (GLOBALS.DEBUG & GLOBALS.DEBUG_VIEW)
					trace("[BottomPanel][addChild][CENTER] my Object height was: " + this.height);
				object.height = this.height;
				object.width  = this.width * 0.28;
				if (GLOBALS.DEBUG & GLOBALS.DEBUG_VIEW)
					trace("[BottomPanel][addChild][CENTER] my Object height now is: " + object.height);
				}
			else if (BPANEL_RIGHT == object.name)
				{
				object.x	 = 1 + this.width * 0.7;
				object.y	 = 1;
				object.height	= this.height * 0.9;
				object.width	= this.width * 0.27;
				}
			else if (BPANEL_RCORNER == object.name)
				{
				object.x	 = 1 + this.width * 0.9;
				object.y	 = 1;
				object.height = this.height;
				}
			super.addChild(object);
			return object;
			}
		public override function removeChild(object:DisplayObject):DisplayObject
			{
			super.removeChild(object);
			return object;
			}
		}
}
